<?php

namespace App\Http\Controllers;

use App\Http\Requests\GradeRequest;
use App\Models\Grade;
use Illuminate\Http\Request;

class GradeController extends Controller
{
    /**
     * 说明：获取年级列表数据
     *
     * @return
     * @param   type
     * @author  daixinguo (daixinguo57@163.com)
     */
    public function index(GradeRequest $request)
    {
        $list = Grade::query()
            // ->where('id', '>', 3)
            ->get();
        $data = [
            'code' => 0,
            'msg' => 'success',
            'data' => $list
        ];
        return response()->json($data, 200);
    }

    /**
     * 说明：新增年级
     *
     * @return
     * @param   type
     * @author  daixinguo (daixinguo57@163.com)
     */
    public function store(GradeRequest $request)
    {
        Grade::query()->create([
            'name' => $request->get('name')
        ]);
        return response()->json([], 204);
    }
}
